#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
/* 
 * * 1.创建子进程 
 * * 2.父子进程执行不同的逻辑 
 * *     子进程进行进程程序替换 
 * *     父进程进行等待 
 * * */
int main(){
    pid_t pid = fork();
    if(pid < 0){
        printf("fork failed\n");
        return 0;
    }else if(pid == 0)
    {        
        //child
        printf("i am child, start exec...\n");
        execl("/usr/bin/ls", "ls", "-a", "-l", NULL);
        printf("if you see the msg, exec failed\n");
    }else{
        //father        
        printf("i am father, i prepare wait child process\n");
        wait(NULL);
    }
    return 0;
}
